﻿/**
 * クリックイベントClass
 * @param {Object} obj
 */
var tmp="0";
var OpInf=function(obj){
	this.obj = obj;
	//alert("tmp:"+tmp);

}

var opInf = new OpInf("");

OpInf.prototype.opClick = function(tableCellObj){
	//alert("tmp2:"+tmp);
	//scroll生成
	var frmScroll = new Cscroll("opBoard",tmp); //スクロール対象のid
	frmScroll.init();
	tmp="1";
//	var element = document.getElementById(obj);
//	var childs = elements.childNodes;
//	for(i=1; i<childs.length; i++){
		//alert("sampleの１個目の子のHTMLは「"+childs[i].innerHTML+"」です");
//	}

	this.opCreate(tableCellObj);
}
OpInf.prototype.opCreate = function(tableCellObj){

    //OP情報のHTML作成
	var html = "";
    var htmlBtn = "";

	var lblTime = "";
	var lineCd = "";
	var processCd = "";

	var tableRowObj = tableCellObj.parentNode;
	try{
		var elements = tableRowObj.cells[0].getElementsByTagName("INPUT");
		if(elements){
			for(var i=0;i<elements.length;i++){
				switch(elements[i].name){
					case "lblTime":
						lblTime = elements[i].value;
						break;
					case "lineCd":
						lineCd = elements[i].value;
						break;
				}
			}
		}
	}catch(e){}

	// 列情報
	html += "<table width='100%'>\n";

	try{
		// TABLE-CELL エレメントから入力の情報を取得する
		var elements = tableCellObj.getElementsByTagName("INPUT");

		if(elements){
			for(var i=0;i<elements.length;i++){

				switch(elements[i].name){
					case "detail_value":
						var bgColor = elements[i].style.backgroundColor;
						html += "<tr>\n";

						html += "	<td align='left' style='padding-left:10px;border:1px solid #D5D7D1; background-color:"+bgColor+";'>\n";
						html += ""+elements[i].value+"\n";
						html += "	</td>\n";

						html += "</tr>\n";
						break;
					case "processCd":
						processCd = elements[i].value;
						break;
				}
			}
		}

	}catch(e){}

	html += "</table>\n";

	htmlBtn ="";

	htmlBtn += "<table>\n";
	htmlBtn += "<tr>\n";
	htmlBtn += "	<td  >　　　　　　";
	htmlBtn += "		<button class='opBtn' onclick = 'back();'>Close</button>";
	htmlBtn += "	</td>";

	htmlBtn += "</tr>\n";
	htmlBtn += "</table>\n";

	document.getElementById("opBoard").innerHTML = html;
	document.getElementById("opBoardBtn").innerHTML = htmlBtn;

	document.getElementById("opBoardInf").innerHTML = "・Line code:　"+lineCd+"<br>・Process No　 　:"+processCd+" "+lblTime+"";


	document.getElementById("opBoard").style.display = "inline";
	document.getElementById("opBoardButtom").style.display = "inline";
	document.getElementById("opBoardBtn").style.display = "inline";
	document.getElementById("opBoardTop").style.display = "inline";
	document.getElementById("opBoardInf").style.display = "inline";

	document.getElementById("mhBoard").style.display = "none";


}

/**
 * 目標パップアップ
 * @param {Object} obj
 */
OpInf.prototype.mhClick = function(tableCellObj){

	var lblDate = "";
	var lblTime = "";
	var lineCd = "";
	var lineNm = "";
	var lblPlanKako = "";
	var lblResKako = "";
	var tableRowObj = tableCellObj.parentNode;
	try{
		var elements = tableRowObj.cells[0].getElementsByTagName("INPUT");
		if(elements){
			for(var i=0;i<elements.length;i++){
				switch(elements[i].name){
					case "lblDate":
						lblDate = elements[i].value;
						break;
					case "lblTime":
						lblTime = elements[i].value;
						break;
					case "lineCd":
						lineCd = elements[i].value;
						break;
					case "lineNm":
						lineNm = elements[i].value;
						break;
					case "lblPlanKako":
						lblPlanKako = elements[i].value;
						break;
					case "lblResKako":
						lblResKako = elements[i].value;
						break;
				}
			}
		}
	}catch(e){}

	var html = "";

	//生産数情報
	html += "<table width='100%' height='100%'  onTouchstart = 'back();'>\n";

	html += "<tr>\n";
	html += "	<td  align='center' style='border:1px solid black; background-color:#FFCC99;'>\n";
	html += "		<table style='background-color:#fffcff; border:2px solid black;'>\n";

	html += "			<tr>\n";
	html += "				<td class='mhTitle'>Line name</td>\n";
	html += "				<td class='mhInfo' align='center' align='center'>"+lineNm+"</td\n";
	html += "			</tr>\n";

	html += "			<tr>\n";
	html += "				<td class='mhTitle'>Line code</td>\n";
	html += "				<td class='mhInfo' align='center'>"+lineCd+"</td\n";
	html += "			</tr>\n";

	html += "			<tr>\n";
	html += "				<td class='mhTitle'>Date</td>\n";
	html += "				<td class='mhInfo' align='center'>"+lblDate+"</td\n";
	html += "			</tr>\n";

	html += "			<tr>\n";
	html += "				<td class='mhTitle'>Time</td>\n";
	html += "				<td class='mhInfo' align='center'>"+lblTime+"</td\n";
	html += "			</tr>\n";

	html += "			<tr>\n";
	html += "				<td class='mhTitle'>Hourly production volume </td>\n";
	html += "				<td class='mhInfo' align='center'>"+lblPlanKako+"</td\n";
	html += "			</tr>\n";

	html += "			<tr>\n";
	html += "				<td class='mhTitle'>production quantity</td>\n";
	html += "				<td class='mhInfo' align='center'>"+lblResKako+"</td\n";
	html += "			</tr>\n";


	html += "		</table>\n";
	html += "	</td>\n";
	html += "</tr>\n";

	html += "</table>\n";



	htmlBtn ="";

	htmlBtn += "<table>\n";
	htmlBtn += "<tr>\n";
	htmlBtn += "	<td  >　　　　　　";
	htmlBtn += "		<button class='opBtn' onclick = 'back();'>Close</button>";
	htmlBtn += "	</td>";

	htmlBtn += "</tr>\n";
	htmlBtn += "</table>\n";

	document.getElementById("opBoardBtn").innerHTML = htmlBtn;
	document.getElementById("mhBoard").innerHTML = html;

	document.getElementById("opBoardButtom").style.display = "inline";
	document.getElementById("opBoardBtn").style.display = "inline";
	document.getElementById("opBoardTop").style.display = "inline";
	document.getElementById("opBoardTop").style.color = "inline";
	document.getElementById("mhBoard").style.display = "inline";

	document.getElementById("opBoardInf").style.display = "none";
	document.getElementById("opBoard").style.display = "none";
}

